Skip to content

@W-18706176: Changes to download latest release version of the API#231

Merged
unandyala merged 15 commits intomainfrom
unandyala.download-latest-release-spec
Jun 12, 2025
Merged

@W-18706176: Changes to download latest release version of the API#231
unandyala merged 15 commits intomainfrom
unandyala.download-latest-release-spec

Conversation

@unandyala
Copy link
Collaborator

@unandyala unandyala commented Jun 4, 2025

@W-18706176 @W-18763414

  1. Get latest version form all the version groups (V1, V2) of an API. This is to suuport Shopper Baskets V1 and V2
  2. Remove the deprecated deployment flag
  3. Added tests exchangeDirectoryParser to meet the coverage threshold
  4. Spilt the test for exchangeDownloader.ts as there is a warning on the file size
  5. All the code is behind isOas flag

Testing

  1. download command
    node bin/run download --dest=raml-test --search='category:Visibility = "External"' --log-level=debug

  2. ran updateApis script in commerce-isomorphic-sdk

@vcua-mobify
Copy link
Contributor

Thanks for this @unandyala . The changes have ensured that I download the latest stable oas specs.

I wonder if we want to have a toggle where we can disable the check? Just wondering if pulling a snapshot spec for testing purposes is a valid use case we have to account for.

@unandyala
Copy link
Collaborator Author

Thanks for this @unandyala . The changes have ensured that I download the latest stable oas specs.

I wonder if we want to have a toggle where we can disable the check? Just wondering if pulling a snapshot spec for testing purposes is a valid use case we have to account for.

I don't think we need other versions. There will be lot of them and they are mainly developer versions. They may not even have backend implementation

@unandyala unandyala changed the title WIP: Changes to download latest release version of the API @W-18706176: Changes to download latest release version of the API Jun 6, 2025
@unandyala unandyala marked this pull request as ready for review June 6, 2025 18:01
@unandyala unandyala requested a review from a team as a code owner June 6, 2025 18:01
Copy link
Collaborator

@joeluong-sfcc joeluong-sfcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change correct? Other than the minor comments, this PR LGTM, but could you update the CHANGELOG for this change?

asset.id = "893f605e-10e2-423a-bdb4-f952f56eb6d8/shopper-customers/0.5.0";
asset.version = "0.5.0";
asset.fatRaml.externalLink = "https://somewhere/fatraml.zip";
it("searches Exchange and returns multiple version groupd", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it("searches Exchange and returns multiple version groupd", () => {
it("searches Exchange and returns multiple version groups", () => {

return releaseSemverRegex.test(version.version);
});
// Sort versions and get the latest
return releaseAssetVersions.sort((instanceA, instanceB) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is a nice solution, it feels like a very clean way to get the latest version, straightforward to understand

ramlToolLogger.warn(DEPLOYMENT_DEPRECATION_WARNING);
}

export async function search(query: string): Promise<RestApi[]> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're planning to search based on the API SDK Type and Visibility categories/types correct? Previously we queried by name... How does it look now when we call search function in the SDKs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For node sdk, it will be
await download.search( 'category:Visibility = "External" category:"SDK Type" = "Commerce"' );

For isomorphic sdk, it will be
await download.search( 'category:Visibility = "External" category:"SDK Type" = "Commerce"' category:"SDK Type" = "Isomorphic"' );

* @returns {Promise<string>} Returned the version string from the instance fetched asset.version value
*/
export async function getVersionByDeployment(
export async function getApiVersions(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear in the description or the function name that we get the latest version, we should rename this function to something like getLatestApiVersions and/or update the JS doc description

Copy link
Contributor

@vcua-mobify vcua-mobify Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since getApiVersions is a new function, can we keep the old getVersionByDeployment still?
Would keeping getVersionByDeployment make this a non-breaking change?

Does raml-toolkit have other users aside from commerce-sdk / commerce-sdk-isomorphic? This change would break those, if they exists.

Also, if we're going to be making a breaking change here, are there other breaking changes we also want to get in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We marked deployment flag as deprecated a while back. So I think it is ok to change the function name.
The raml-toolkit is only used by commerce-sdk / commerce-sdk-isomorphic

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to put all the new code behind isOas flag


return Promise.all(promises).then((results) =>
results.reduce((acc, val) => acc.concat(val), [])
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't immediately clear to me what this does, could you add a small comment?

vcua-mobify
vcua-mobify previously approved these changes Jun 11, 2025
Copy link
Contributor

@vcua-mobify vcua-mobify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for refactoring this PR to be a non-breaking change! Good idea to use the isOas to feature flag all of the changes.

LGTM

chai.use(chaiAsPromised);
});

describe("extractFile", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. From the looks of it, we were only testing extractFiles before and not extractFile.

ramlToolLogger.error(
`${logPrefix} The rest API ${restApi.assetId} is missing asset.versionGroups`
);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good idea to give the API team a heads up about this since I don't know if everything defines a versionGroup.

joeluong-sfcc
joeluong-sfcc previously approved these changes Jun 11, 2025
Copy link
Collaborator

@joeluong-sfcc joeluong-sfcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only thing has the CI always failed since we added OAS support in RAML toolkit, or did it start with this PR? Either way we should resolve the CI so that tests pass

@unandyala
Copy link
Collaborator Author

LGTM, only thing has the CI always failed since we added OAS support in RAML toolkit, or did it start with this PR? Either way we should resolve the CI so that tests pass

this is an existing issue not related to the PR - /bin/sh: 1: oasdiff: not found
Error: oasdiff is not installed. Install oasdiff according to https://github.com/oasdiff/oasdiff#installation

@unandyala unandyala dismissed stale reviews from joeluong-sfcc and vcua-mobify via 18916b8 June 11, 2025 20:10
Copy link
Contributor

@vcua-mobify vcua-mobify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the CI issue @unandyala

@unandyala unandyala merged commit fc946fc into main Jun 12, 2025
7 checks passed
@unandyala unandyala deleted the unandyala.download-latest-release-spec branch June 12, 2025 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants